﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterForum.master" AutoEventWireup="true" CodeFile="messaggi.aspx.cs" Inherits="src_mess" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link rel="stylesheet" type="text/css" href="/FORUMDEFINITIVO/css/forum.css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="main">
        <div id="left-part">
            <%
                String scelta = Request.QueryString["scelta"];
            %>
            <h1>Messaggi</h1>
            <ul id="subnavi">
                <% Response.Write("<li"); if (scelta == "msg" || scelta == null) Response.Write(" class=\"active\" "); else Response.Write(""); %>><a
                    href="?scelta=msg">Messaggi</a></li>
                <% Response.Write("<li"); if (scelta == "writemsg") Response.Write(" class=\"active\" "); else Response.Write(""); %>><a
                    href="?scelta=writemsg">Scrivi Messaggio</a></li>
                <% Response.Write("<li"); if (scelta == "msgsend") Response.Write(" class=\"active\" "); else Response.Write(""); %>><a href="?scelta=msgsend">Messaggi inviati</a></li>
                <% Response.Write("<li"); if (scelta == "blockusr") Response.Write(" class=\"active\" "); else Response.Write(""); %>><a href="?scelta=msgrec">Messaggi ricevuti</a></li>
            </ul>
            <h1>Regolamento</h1>
            <p>
                È severamente vietato insultare e/o offendere altri utenti, religioni , etnie ,
                sessi , orientamenti sessuali, nel caso in cui questi regolamenti non vengono rispettati
                saremo obbligati a bannarvi l'account.
            </p>
        </div>
        <div id="right-part">
            <% if (scelta == "msg" || scelta == null)
               {
                   int count = 0;

                   Response.ContentType = "text/html";
                   Response.Write("<div class=\"datagrid\">");
                   Response.Write("<table>");
                   Response.Write("<thead>");
                   Response.Write("<tr>");
                   Response.Write("<th>TITOLO</th>");
                   Response.Write("<th>TESTO</th>");
                   Response.Write("<th>SENDER</th>");
                   Response.Write("<th>RECEIVER</th>");
                   Response.Write("</tr>");
                   Response.Write("</thead>");
                   Response.Write("<tbody>");
                   foreach (String s in utenteCore.AllIdMessage(utente.username))
                   {
                       count++;
                       if (count % 2 != 0)
                       {
                           Response.Write("<tr>");
                           Response.Write("<td>" + utenteCore.AllTitleMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllTextMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllSenderMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllReceiverMessage(s)[0] + "</td>");
                           Response.Write("</tr>");
                       }
                       else
                       {
                           Response.Write("<tr class=\"alt\">");
                           Response.Write("<td>" + utenteCore.AllTitleMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllTextMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllSenderMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllReceiverMessage(s)[0] + "</td>");
                           Response.Write("</tr>");
                       }
                   }
                   if (utenteCore.AllIdMessage(utente.username).Count == 0)
                   {
                       Response.Write("<tr>");
                       Response.Write("<td>Non ci sono Messaggi</td>");
                       Response.Write("</tr>");
                   }
                   Response.Write("</tbody>");
                   Response.Write("</table>");
                   Response.Write("</div>");
                   Response.Write("<br/>");
                   Response.Write("<br/>");
                   Response.Write("<br/>");

                   
            %>
            <%}
               else if (scelta == "writemsg")
               {%>
            <div id="Div1">
                <div class="datagrid">
                    <table>
                        <thead>
                            <tr>
                                <th class="style2">A:
                                </th>
                                <th class="style3">
                                    <asp:TextBox ID="TBAchi" runat="server" Width="301px" Style="margin-left: 0px"
                                        OnTextChanged="TBAchi_TextChanged"></asp:TextBox>
                                </th>

                            </tr>
                        </thead>
                        <thead>
                            <tr>
                                <th class="style1">Oggetto:
                                </th>
                                <th>
                                    <asp:TextBox ID="TBOggetto" runat="server" Style="margin-left: 0px"
                                        Width="300px"></asp:TextBox>
                                </th>

                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <div id="Div2">
                <div class="datagrid">
                    <tbody>
                        <th>

                            <asp:TextBox ID="TBTesto" runat="server" Height="278px" Width="650px"
                                TextMode="MultiLine"></asp:TextBox>
                        </th>


                    </tbody>
                    </table>
                </div>
            </div>
            <asp:Button ID="TBInviaMessaggio" runat="server" Style="margin-left: 1px"
                Text="Invia" OnClick="TBInviaMessaggio_Click" />
            <%}
               else if (scelta == "msgsend")
               {
                   int count = 0;

                   Response.ContentType = "text/html";
                   Response.Write("<div class=\"datagrid\">");
                   Response.Write("<table>");
                   Response.Write("<thead>");
                   Response.Write("<tr>");
                   Response.Write("<th>TITOLO</th>");
                   Response.Write("<th>TESTO</th>");
                   Response.Write("<th>SENDER</th>");
                   Response.Write("<th>RECEIVER</th>");
                   Response.Write("</tr>");
                   Response.Write("</thead>");
                   Response.Write("<tbody>");
                   foreach (String s in utenteCore.AllIdMessageSend(utente.username))
                   {
                       count++;
                       if (count % 2 != 0)
                       {
                           Response.Write("<tr>");
                           Response.Write("<td>" + utenteCore.AllTitleMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllTextMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllSenderMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllReceiverMessage(s)[0] + "</td>");
                           Response.Write("</tr>");
                       }
                       else
                       {
                           Response.Write("<tr class=\"alt\">");
                           Response.Write("<td>" + utenteCore.AllTitleMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllTextMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllSenderMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllReceiverMessage(s)[0] + "</td>");
                           Response.Write("</tr>");
                       }
                   }
                   if (utenteCore.AllIdMessageSend(utente.username).Count == 0)
                   {
                       Response.Write("<tr>");
                       Response.Write("<td>Non ci sono Messaggi</td>");
                       Response.Write("</tr>");
                   }
                   Response.Write("</tbody>");
                   Response.Write("</table>");
                   Response.Write("</div>");
                   Response.Write("<br/>");
                   Response.Write("<br/>");
                   Response.Write("<br/>");

            %>
            <%
               }
               else if (scelta == "msgrec")
               {

                   int count = 0;

                   Response.ContentType = "text/html";
                   Response.Write("<div class=\"datagrid\">");
                   Response.Write("<table>");
                   Response.Write("<thead>");
                   Response.Write("<tr>");
                   Response.Write("<th>TITOLO</th>");
                   Response.Write("<th>TESTO</th>");
                   Response.Write("<th>SENDER</th>");
                   Response.Write("<th>RECEIVER</th>");
                   Response.Write("</tr>");
                   Response.Write("</thead>");
                   Response.Write("<tbody>");
                   foreach (String s in utenteCore.AllIdMessageRec(utente.username))
                   {
                       count++;
                       if (count % 2 != 0)
                       {
                           Response.Write("<tr>");
                           Response.Write("<td>" + utenteCore.AllTitleMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllTextMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllSenderMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllReceiverMessage(s)[0] + "</td>");
                           Response.Write("</tr>");
                       }
                       else
                       {
                           Response.Write("<tr class=\"alt\">");
                           Response.Write("<td>" + utenteCore.AllTitleMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllTextMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllSenderMessage(s)[0] + "</td>");
                           Response.Write("<td>" + utenteCore.AllReceiverMessage(s)[0] + "</td>");
                           Response.Write("</tr>");
                       }
                   }
                   if (utenteCore.AllIdMessageRec(utente.username).Count == 0)
                   {
                       Response.Write("<tr>");
                       Response.Write("<td>Non ci sono Messaggi</td>");
                       Response.Write("</tr>");
                   }
                   Response.Write("</tbody>");
                   Response.Write("</table>");
                   Response.Write("</div>");
                   Response.Write("<br/>");
                   Response.Write("<br/>");
                   Response.Write("<br/>");
                   
            %>
            <%} %>
        </div>
    </div>
</asp:Content>

